//
//  Setting.swift
//  lottery
//
//  Created by admin on 16/2/3.
//  Copyright © 2016年 jin. All rights reserved.
//

import UIKit

class Setting: NSObject {
    var title:String
    var titleImage:UIImage!
    var accessoryImage:UIImage!
    var block:(()->())!
    var accessory:UIView!
    // 初始化
    convenience init(title:String,titleImage:UIImage,accessoryImage:UIImage,block:()->())
    {
        self.init(title:title,titleImage:titleImage)
        self.accessoryImage = accessoryImage
        self.block = block
    }
    convenience init(title:String,titleImage:UIImage,accessoryImage:UIImage)
    {
        self.init(title:title,titleImage:titleImage)
        self.accessoryImage = accessoryImage
    }
    convenience init(title:String,titleImage:UIImage,accessory:UISwitch)
    {
        self.init(title:title,titleImage:titleImage)
        accessory.on = NSUserDefaults.standardUserDefaults().boolForKey(self.title)
        self.accessory = accessory
    }
    convenience init(title:String,titleImage:UIImage,lable:UILabel)
    {
        self.init(title:title,titleImage:titleImage)
        self.accessory = lable
    }
    private init(title:String,titleImage:UIImage)
    {
        self.title = title
        self.titleImage = titleImage
    }
    init(title:String,accessoryImage:UIImage) {
        self.title = title
        self.accessoryImage = accessoryImage
    }
    func switchChange(switcha:UISwitch)
    {
        let userDefault = NSUserDefaults.standardUserDefaults()
        userDefault.setBool(switcha.on, forKey: self.title)
        userDefault.synchronize()
    }
    
}
